/*
 * Copyright 2005-2013 finalist.cn. All rights reserved.
 * Support: http://www.finalist.cn
 * License: http://www.finalist.cn/license
 */
package com.finalist.dao.impl;

import java.util.List;

import javax.persistence.FlushModeType;

import org.springframework.stereotype.Repository;

import com.finalist.dao.OrderItemDao;
import com.finalist.entity.Order;
import com.finalist.entity.OrderItem;

/**
 * Dao - 订单项
 * 
 * @author Finalist IT Group
 * @version 3.0
 */
@Repository("orderItemDaoImpl")
public class OrderItemDaoImpl extends BaseDaoImpl<OrderItem, Long> implements OrderItemDao
{

    @SuppressWarnings("unchecked")
    @Override
    public List<Order> getOrderListByKeyWord(String name)
    {
        if (name == null)
        {
            name = "";
        }

        String jpql = "select  distinct orderItem.order from OrderItem orderItem where orderItem.name like '%" + name + "%'  or orderItem.sn=:sn";
        return entityManager.createQuery(jpql).setFlushMode(FlushModeType.COMMIT).setParameter("sn", name).getResultList();
    }
}